Skip to content

Completed assignment 1#1

Open
elioc1341 wants to merge 1 commit intomainfrom
assignment-1
Open

Completed assignment 1#1
elioc1341 wants to merge 1 commit intomainfrom
assignment-1

Conversation

@elioc1341
Copy link
Owner

What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)

Completed Assignment 1. The following files have had code added:

  • assignment_1.ipynb

What did you learn from the changes you have made?

I have a bit of experience with Python, so there were two main learnings from this assignment.

  1. Learning and getting comfortable with Jupyter - it was great having the demo in class, but during the assignment I got to get much more comfortable with it.
  2. Finding differences between sort() and sorted(). I was pretty sure to use a sorting function, but sort was not giving me what I needed for the assignment, so I needed to look into it further and find that sort doesn't actually return anything if I was trying to check my progress in building the anagram checker.

Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?

  • I initially used nested if statements and got it working. They would check if is_case_sensitive is true, and then pasting the same code from Part 1, but excluding using lower() function if is_case_sensitive is true. I ended up going this method because it's easier to follow/read/grade.
  • Aside from that, we could also use upper() instead of lower() when comparing non-case sensitive words.

Were there any challenges? If so, what issue(s) did you face? How did you overcome it?

  • I was initially trying to use the sort function instead of sorted, and was becoming confused when it wasn't returning the sorted list when testing. I ended up googling the Python documentation and stackoverflow to understand that sort doesn't return anything, but the sorted function does.
  • I also learned that strings are immutable, which means the letters can't be broken down and sorted in alphabetic order using sort.
  • I was worried my initial attempt of using a nested if statement would be to difficult to grade/read so I rewrote it so that the format would be easier to follow.

How were these changes tested?

  • I tried breaking down the problem into steps, and testing to return each component indivudally:
  1. Returning sorted word_a
  2. Returning sorted and lowercase word_a
  3. Returning sorted and lowercase word_b
  4. Returning True/False if they pass condition of being equal

For Part 2, I also tested returning the compare_a and compare_b values when the is_case_sensitive was set to True/False.

A reference to a related issue in your repository (if applicable)

N/A

Checklist

  • I can confirm that my changes are working as intended

Copy link

@juliagallucci juliagallucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of lower() and sorted(). One note for improvement, you don’t need to write if return True else return False — since the comparison itself returns a boolean, you can just return sorted(...) == sorted(...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants